package cn.zzu.Etrip.oneday.activity;

import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
import android.widget.Toast;

import com.example.administrator.etrip.R;

import cn.zzu.Etrip.twoday.activity.TwoDayPayActivity;

public class oneday_pay extends AppCompatActivity {
    TextView text_price,text_happy;
    RadioGroup rg;
    RadioButton rd1,rd2;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.oneday_local_pay);
        Intent intent=getIntent();
        int id=intent.getExtras().getInt("photo");
        final int price=intent.getIntExtra("价格",0);
        double happy=intent.getDoubleExtra("xxx",2)*20;
        final String place=intent.getStringExtra("目的地");
        text_price=findViewById(R.id.text_price);
        text_happy=findViewById(R.id.text_happy);
        text_price.setText("费用包含（"+price+"$)");
        text_happy.setText((int)happy+"%满意   100位给出了评价\r\n非常满意（"+happy+"）");
        rg=findViewById(R.id.RG);
        rd1=(RadioButton) findViewById(R.id.RB1);
        rd2=(RadioButton) findViewById(R.id.RB2);
        ImageView im=findViewById(R.id.title1);
       im.setImageResource(id);
        Button payfor=findViewById(R.id.button_yuding);
        payfor.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                AlertDialog.Builder pay = new AlertDialog.Builder(oneday_pay.this);
                pay.setTitle("立即订购");
                pay.setMessage("☆☆☆请确定订购☆☆☆");
                pay.setIcon(R.mipmap.a);
                pay.setNegativeButton("关闭",
                        new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {

                            }
                        });
                pay.setPositiveButton("确定",
                        new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                AlertDialog.Builder finalResult = new AlertDialog.Builder(oneday_pay.this);
                                finalResult.setMessage("☺☺☺☺成功☺☺☺☺");
                                finalResult.setPositiveButton("关闭", new DialogInterface.OnClickListener() {
                                    @Override
                                    public void onClick(DialogInterface dialog, int which) {
                                        Intent intent=new Intent(oneday_pay.this,oneday_database.class);

                                        Boolean is=rd1.isChecked();
                                        Boolean is2=rd2.isChecked();
                                        if(is){
                                            intent.putExtra("number",1);
                                        }else if(is2){
                                            intent.putExtra("number",2);
                                        }else{
                                            intent.putExtra("number",2);
                                        }
                                        intent.putExtra("目的地",place);
                                        intent.putExtra("singleprice",price);
                                        startActivity(intent);
                                    }
                                });
                                finalResult.create();
                                finalResult.show();
                            }
                        });
                pay.show();
            }
        });
    }

}
